home *** CD-ROM | disk | FTP | other *** search
- #!/bin/bash -e
-
- merge_debconf_into_conf()
- {
- local tmpfile; tmpfile="$1"
- local setting; setting="$2"
- local template; template="$3"
-
- db_get "$template"
- local value; value="$(echo "$RET" | sed -e 's,[$`"\],\\&,g; s,[\@],\\&,g')"
- if grep -q "^${setting}=" "$tmpfile"; then
- sed -i -re "s@^(${setting}=).*@\1\"${value}\"@" "$tmpfile"
- else
- echo >> "$tmpfile"
- echo "${setting}=\"${value}\"" >> "$tmpfile"
- fi
- }
-
- case "$1" in
- configure)
- . /usr/share/debconf/confmodule
-
- case grub-pc in
- grub-pc)
-
- if grep -q "[= ]/sbin/update-grub" /etc/kernel-img.conf 2> /dev/null ; then
- echo -e "\n/etc/kernel-img.conf still contains /sbin/update-grub in the hooks." >&2
- echo -e "Running sed over it to remove the /sbin/ prefix.\n" >&2
- sed -i /etc/kernel-img.conf -e "s,\(.*\) */sbin/update-grub$,\1 update-grub,g"
- fi
- mkdir -p /boot/grub
-
- if test -e /boot/grub/device.map && ! test -e /boot/grub/core.img ; then
- # Looks like your device.map was generated by GRUB Legacy, which
- # used to generate broken device.map (see #422851). Avoid the risk
- # by regenerating it.
- grub-mkdevicemap --no-floppy
- fi
- ;;
- esac
-
- tmp_default_grub="$(mktemp "/tmp/grub.XXXXXXXXXX")"
- trap "rm -f ${tmp_default_grub}" EXIT
- cp -p /usr/share/grub/default/grub ${tmp_default_grub}
-
- merge_debconf_into_conf "$tmp_default_grub" GRUB_CMDLINE_LINUX grub2/linux_cmdline
- merge_debconf_into_conf "$tmp_default_grub" GRUB_CMDLINE_LINUX_DEFAULT grub2/linux_cmdline_default
-
- case grub-pc in
- grub-pc)
- merge_debconf_into_conf "$tmp_default_grub" GRUB_TIMEOUT grub-pc/timeout
- db_get grub-pc/hidden_timeout
- if [ "$RET" = false ]; then
- sed -i -e 's/^GRUB_HIDDEN_TIMEOUT=/#&/' "$tmp_default_grub"
- fi
- ;;
- esac
-
- ucf --three-way --debconf-ok --sum-file=/usr/share/grub/default/grub.md5sum ${tmp_default_grub} /etc/default/grub
- package="$(ucfq --with-colons /etc/default/grub | cut -d : -f 2)"
- if echo $package | grep -q "^grub-" ; then
- ucfr --force grub-pc /etc/default/grub
- else
- ucfr grub-pc /etc/default/grub
- fi
-
- case grub-pc in
- grub-pc)
-
- if test -e /boot/grub/stage2 && test -e /boot/grub/menu.lst && ! test -e /boot/grub/core.img ; then
- db_get grub-pc/chainload_from_menu.lst
- if $RET ; then
- # Create core.img (but do not risk writing to MBR).
- echo "Generating core.img" >&2
- grub-install --no-floppy --grub-setup=/bin/true "(hd0)" > /dev/null
-
- # Update menu.lst to reflect that:
- # - core.img is present now
- # - core.img has to be the first option
- echo "Saving menu.lst backup in /boot/grub/menu.lst_backup_by_grub2_postinst" >&2
- cp /boot/grub/menu.lst{,_backup_by_grub2_postinst}
- echo "Running update-grub Legacy to hook our core.img in it" >&2
- LET_US_TRY_GRUB_2=true /usr/lib/grub-legacy/update-grub 2>&1 | sed -e "s/^/ /g" >&2
- # We just hooked GRUB 2 in menu.lst; then also generate grub.cfg.
- touch /boot/grub/grub.cfg
- fi
- else
- db_subst grub-pc/install_devices CHOICES `grub-mkdevicemap -m - | sed -e "/^(fd[0-9]\+)/d;s,.*\t,,g" | tr '\n' ',' | sed -e 's/,$//g;s/,/, /g'`
- db_input high grub-pc/install_devices || true
- db_go
- db_get grub-pc/install_devices
- for i in `echo $RET | sed -e 's/,/ /g'` ; do
- if grub-install --no-floppy $i ; then
- # We just installed GRUB 2; then also generate grub.cfg.
- touch /boot/grub/grub.cfg
- fi
- done
- fi
-
- # /boot/grub/ has more chances of being accessible by GRUB
- if test -e /boot/grub/grub.cfg ; then
- for i in /usr/share/grub/unicode.pf2 /usr/share/images/desktop-base/moreblue-orbit-grub.png ; do
- if test -e $i ; then
- cp $i /boot/grub/
- fi
- done
- fi
-
- ;;
- esac
-
- # If grub.cfg has been generated, update it.
- if test -e /boot/grub/grub.cfg ; then
- update-grub
- fi
- ;;
- abort-upgrade|abort-remove|abort-deconfigure)
- ;;
- *)
- echo "postinst called with unknown argument \`$1'" >&2
- exit 1
- ;;
- esac
-
- # dh_installdeb will replace this with shell code automatically
- # generated by other debhelper scripts.
-
-
-
- exit 0
-